<include file="Public/sui_header" />
<div style="font-size:1.2em;margin-top: 0.8rem;">
    <span class="color-block">&nbsp;</span>&nbsp;定制导游合同
</div>
<form method="post">
<div class="card">
    <div class="card-content">
        <div class="card-content-inner">
            <div class="list-block">
                <ul>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">导游姓名</div>
                                <div class="item-input">
                                    {$guider['name']}
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">目的地</div>
                                <div class="item-input">
                                    {$guider['location']}
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">开始时间</div>
                                <div class="item-input">
                                    {$custonizeguider['start_time']|date="Y-m-d", ###}
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">结束时间</div>
                                <div class="item-input">
                                    {$custonizeguider['end_time']|date="Y-m-d", ###}
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">价格</div>
                                <div class="item-input">
                                    ￥{$custonizeguider['price']}/天
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">总价</div>
                                <div class="item-input">
                                    ￥{$custonizeguider['amount']}
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">行程详情</div>
                                <div class="item-input">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner" style="display: block;overflow: auto;">
                                {$custonizeguider['content']|html_entity_decode}
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">合同细则</div>
                                <div class="item-input">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner" style="display: block;overflow: auto;">
                                {$contract|html_entity_decode}
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">用户补充合同</div>
                                <div class="item-input">
                                </div>
                            </div>
                        </div>
                    </li>
                    <if condition="($custonizeguider['user_contract_state'] eq '已签署') AND ($custonizeguider['guider_contract_state'] eq '已签署')">
                        <li>
                            <div class="item-content">
                                <div class="item-inner" style="display: block;overflow: auto;">
                                    {$custonizeguider['user_contract']|html_entity_decode}
                                </div>
                            </div>
                        </li>
                        <li>
                    <else/>
                            <li>
                                <div class="item-content">
                                    <div class="item-inner">
                                        <div class="item-input">
                                            <textarea name="user_contract" placeholder="请填写补充合同">{$custonizeguider['user_contract']|html_entity_decode}</textarea>
                                        </div>
                                    </div>
                                </div>
                            </li>
                    </if>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">导游补充合同</div>
                                <div class="item-input">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner" style="display: block;overflow: auto;">
                                {$custonizeguider['guider_contract']|html_entity_decode}
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">签约情况</div>
                                <div class="item-input">
                                    用户{$custonizeguider['user_contract_state']}
                                    <if condition="$custonizeguider['user_contract_time'] neq 0">{$custonizeguider['user_contract_time']|date="Y-m-d",###}</if>
                                    <br/> 导游{$custonizeguider['guider_contract_state']}
                                    <if condition="$custonizeguider['guider_contract_time'] neq 0">{$custonizeguider['guider_contract_time']|date="Y-m-d",###}</if>
                                    <br/>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<if condition="($custonizeguider['user_contract_state'] eq '已签署') AND ($custonizeguider['guider_contract_state'] eq '已签署')">
    <!-- 都签署，无修改和同意按钮 -->
<else/>
    <div class="row detail-submit">
        <if condition="($custonizeguider['user_contract_state'] eq '已签署') AND ($custonizeguider['guider_contract_state'] eq '已签署')">
            <!-- 都签署，无修改和同意按钮 -->
        <else/>
            <div class="col-50">
                <input type="submit" class="button button-big button-fill button-info close-panel" value="修改" onclick="return confirm('修改合同内容会将双方签署状态全部修改为未签署，是否修改?');">
            </div>
            <div class="col-50">
                <a href="{:U('Guider/sign', ['id'=>$custonizeguider['id']])}" class="button button-big button-fill button-success" onclick="return confirm('本操作不会更新您的补充合同内容，如需要更新合同内容请点击修改，是否确认同意？');">同意</a>
            </div>
        </if>
    </div>
</if>
</form>
<if condition="($custonizeguider['user_contract_state'] eq '未签署') OR ($custonizeguider['guider_contract_state'] eq '未签署')">
<elseif condition="$custonizeguider['state'] eq '已完成'">
<else/>
    <div style="font-size:1.2em;margin-top: 0.8rem;">
        <span class="color-block">&nbsp;</span>&nbsp;附加合同
    </div>
    <php>
        //所有合同内容 
        $contractOrder = D('ContractOrder')->where(['order_type'=>'customized_guider', 'order_id'=>$custonizeguider['id']])->select(); 
        //最近一个合同是否已经签署完成 
        $lastContract = D('ContractOrder')->where(['order_type'=>'customized_guider', 'order_id'=>$custonizeguider['id']])->order('id desc')->find(); 

        if ((!$lastContract)||(($lastContract['buyer_contract_state'] == '已签署')&&($lastContract['seller_contract_state'] == '已签署'))) { 
            $isNew = true;
        } else { 
            $isNew = false; 
        }
    </php>
    <form method="post">
    <volist name="contractOrder" id="vo">
        <div class="card">
            <div class="card-content">
                <div class="card-content-inner">
                    <div class="list-block">
                        <ul>
                            <li>
                                <div class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title label">用户补充合同</div>
                                        <div class="item-input">
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div class="item-content">
                                    <div class="item-inner" style="display: block;overflow: auto;">
                                        <if condition="($vo['buyer_contract_state'] eq '已签署') AND ($vo['seller_contract_state'] eq '已签署')">
                                            {$vo['buyer_content']|html_entity_decode}
                                        <else/>
                                            <input type="hidden" name="contractOrderId" value="{$vo['id']}"/>
                                            <textarea name="buyer_content" placeholder="请填写补充合同">{$vo['buyer_content']|html_entity_decode}</textarea>
                                        </if>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title label">导游补充合同</div>
                                        <div class="item-input">
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div class="item-content">
                                    <div class="item-inner" style="display: block;overflow: auto;">
                                        {$vo['seller_content']|html_entity_decode}
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title label">签约情况</div>
                                        <div class="item-input">
                                            用户{$vo['buyer_contract_state']}
                                            <if condition="$vo['buyer_contract_time'] neq 0">{$vo['buyer_contract_time']|date="Y-m-d",###}</if>
                                            <br/> 导游{$vo['seller_contract_state']}
                                            <if condition="$vo['seller_contract_time'] neq 0">{$vo['seller_contract_time']|date="Y-m-d",###}</if>
                                            <br/>
                                        </div>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </volist>
    <if condition="!$isNew">
        <!-- 修改合同 -->
        <div class="row detail-submit">
            <php>if ($lastContract['buyer_contract_state'] == '已签署') {</php>
            <div class="col-100">
                <input type="submit" class="button button-big button-fill button-info close-panel" value="修改" onclick="return confirm('修改合同内容会将双方签署状态全部修改为未签署，是否修改?');">
            </div>
            <php>} else {</php>
            <div class="col-50">
                <input type="submit" class="button button-big button-fill button-info close-panel" value="修改" onclick="return confirm('修改合同内容会将双方签署状态全部修改为未签署，是否修改?');">
            </div>
            <div class="col-50">
                <a href="{:U('Guider/sign', ['id'=>$lastContract['id'], 'type'=>'contractOrder'])}" class="button button-big button-fill button-success" onclick="return confirm('本操作不会更新您的补充合同内容，如需要更新合同内容请点击修改，是否确认同意？');">同意</a>
            </div>
            <php>}</php>
        </div>
    </form>
    <else/>
        <!-- 新增合同 -->
        <form method="post">
            <div class="card">
                <div class="card-content">
                    <div class="card-content-inner">
                        <div class="list-block">
                            <ul>
                                <li>
                                    <div class="item-content">
                                        <div class="item-inner">
                                            <div class="item-title label">用户补充合同</div>
                                            <div class="item-input">
                                            </div>
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="item-content">
                                        <div class="item-inner" style="display: block;overflow: auto;">
                                            <textarea name="buyer_content" placeholder="请填写补充合同"></textarea>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row detail-submit">
                <div class="col-50">
                    <a href="#" class="button button-big button-fill button-info close-panel return">返回</a>
                </div>
                <input type="hidden" name="order_type" value="customized_guider">
                <input type="hidden" name="order_id" value="{$custonizeguider['id']}">
                <div class="col-50">
                    <input type="submit" class="button button-big button-fill button-success" value="新增" />
                </div>
            </div>
        </form>
    </if>
</if>

<include file="Public/sui_footer" />
